package com.ug.config.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author LY
 * @create 2024/7/18 9:41
 * @Description 缓存过滤器
 */
@Component
// 自动扫描和注册Servlet相关组件(该注解会扫描指定包及其子包下的所有类，查找标有@WebServlet、@WebFilter、@WebListener等注解)
@ServletComponentScan
@WebFilter(urlPatterns = "/*",filterName = "xssFilter")
public class CacheFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        chain.doFilter(new CacheHttpServletRequestWrapper((HttpServletRequest) request), response);
    }
}
